home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / rbbs_pc / subjct30.zip / SUBJECT.BAS next >
BASIC Source File  |  1990-10-10  |  25KB  |  851 lines

  1. ' --------------------------------------------------------
  2. '
  3. ' Dedicated to the devotional service of Lord Shri Krishna
  4. '
  5. '             by Vaishnava dasa on 10/20/89
  6. '                Release 3.0 on 10/10/90
  7. '
  8. '
  9. ' Version 1.0 (10/20/89)
  10. ' Version 1.1 (10/21/89)
  11. ' Version 1.2 (10/21/89)
  12. ' Version 1.3 (11/28/89)
  13. ' Version 1.4 (12/13/89)
  14. ' Version 1.4 (12/18/89)
  15. ' o Reads format file (default "SUBJECT.TMP" on default drive) for
  16. '     customizing output file using "F:" optional command-line
  17. '     parameter.  Recognizes these format strings:
  18. '     1) TODATExx - date of latest message
  19. '     2) FMDATExx - date of earliest message
  20. '     3) MSG - number of messages in conference
  21. '     4) AREA - name of conference given in command line.  SUBJECT.exe
  22. '               will overwrite 16 characters following "AREA" string
  23. '               when copying from the format file to the output file.
  24. '               This is needed if you make a generic template format
  25. '               file where AREA variables vary in length.  If you are
  26. '               using one template per conference, you can omit this
  27. '               AREA variable and just put the name of the conference
  28. '               in the template file
  29. '     5) SUBJECT8901234567890 - 20 characters for SUBJECT string
  30. '     6) ### - 3 characters for number of messages in SUBJECT thread
  31. '
  32. '     When using new "F:" parameter, all the above format string
  33. '     variables are optional.  Command line parameters "S:", "D:" and
  34. '     "L:" are ignored.  Using the "F:" parameter assumes that you
  35. '     will put in your own Smart-text commands.  Will even work with
  36. '     format files using ansi commands (as done by THEDRAW) as long as
  37. '     the above strings can be found in the format file
  38. '
  39. ' Version 2.0 (12/25/89)
  40. ' Version 2.1 (5/31/90)
  41. ' o  Gets rid of G:, A:, B:, and F:C parameters.
  42. ' o  Compatible with RBBS-PC Version 17.3
  43. ' o  Strips "RE:" from Subjects
  44. '
  45. ' Version 3.0 (10/10/90)
  46. ' o  Got rid of all internal format for Smart-text; this means
  47. '    that (*.tmp) template files are absolutely required
  48. ' o  No more command-line parameters supported except ones
  49. '    absolutely required (i.e. I:, O:, and C:)
  50. ' o  SUBJECT will only support making all three *W.DEF files,
  51. '    namely, *W.DEF, *WG.DEF, and *WC.DEF.  I have no idea if
  52. '    this will be backwardly compatible with RBBS-PC prior to
  53. '    Version 17.3
  54. ' o  Now SUBJECT will support full 25 character SUBJECTs in output
  55. '    This is not backwardly compatible with any previous release of
  56. '    SUBJECT.EXE, or the previous default-sample *.TMP files
  57. '    New sample *.TMP files will be included with this release
  58. '  
  59. ' --------------------------------------------------------
  60. '
  61. ' SUBJECT Version 3.x - A RBBS-PC Conference messages utility
  62. '
  63. ' Use:  Scans RBBS-PC messages files and writes a file listing
  64. ' ~~~   the most popular threads in descending order.  Formatting
  65. '       options dependent solely on required *.TMP template files.
  66. '
  67. DEFINT A-Z
  68. DECLARE SUB comline (n, a$(), max)
  69. DECLARE SUB center (a$, pad, ret)
  70. DECLARE SUB delayit (secs, display)
  71. pad = 1
  72. ret = 1
  73. false = 0
  74. true = NOT false
  75. restrow = 1
  76. restcol = 1
  77. ON ERROR GOTO HANDLER
  78.  
  79. ' DECLARE AN ARRAY TO GET COMMANDLINE PARAMETERS
  80. DIM a$(1 TO 4)
  81. CALL comline(n, a$(), 4)
  82. IF n = 0 THEN GOTO showcommands
  83. FOR showarray = 1 TO 4
  84.   IF INSTR(a$(showarray), "I:") <> 0 THEN
  85.     filename$ = MID$(a$(showarray), 3, 255)
  86.   END IF
  87.   IF INSTR(a$(showarray), "O:") <> 0 THEN
  88.     outputfile$ = MID$(a$(showarray), 3, 255)
  89.   END IF
  90.   IF INSTR(a$(showarray), "C:") <> 0 THEN
  91.     confname$ = MID$(a$(showarray), 3, 12)
  92.   END IF
  93.   IF INSTR(a$(showarray), "?") <> 0 THEN
  94.     helptext = true
  95.   END IF
  96. NEXT showarray
  97. ERASE a$
  98.  
  99. ' IF REQUIRED PARAMETERS MISSING, GOTO SHOW HIM WHAT'S WRONG HERE
  100. IF LEN(filename$) = 0 THEN GOTO showcommands
  101. IF LEN(outputfile$) = 0 THEN GOTO showcommands
  102. IF LEN(confname$) = 0 THEN GOTO showcommands
  103. IF helptext THEN GOTO showcommands
  104.  
  105. ' DEFINE RBBS-PC's MESSAGE HEADER RECORD
  106. TYPE recordtype
  107.   private AS STRING * 1
  108.   numb1mess AS STRING * 4
  109.   namemsgfrom AS STRING * 31
  110.   namemsgto AS STRING * 22
  111.   notused1 AS STRING * 9
  112.   mmdate AS STRING * 2
  113.   notused1a AS STRING * 1
  114.   dddate AS STRING * 2
  115.   notused1b AS STRING * 1
  116.   yydate AS STRING * 2
  117.   subject AS STRING * 25
  118.   notused2 AS STRING * 15
  119.   alive AS STRING * 1
  120.   recnos AS STRING * 4
  121.   notused3 AS STRING * 8
  122. END TYPE
  123.  
  124. ' DEFINE RBBS-PC's CHECKPOINT RECORD
  125. TYPE checkrecord
  126.   maximess AS STRING * 8
  127.   not2used AS STRING * 59
  128.   locatefirstmess AS STRING * 7
  129.   noteverused1 AS STRING * 54
  130. END TYPE
  131.  
  132. ' DEFINE SUBJECT ARRAY
  133. TYPE tosort
  134.   titles AS STRING * 25
  135. END TYPE
  136.  
  137. ' DEFINE SUBJECT ARRAY WITH NUMBER OF COUNT
  138. TYPE tosort2
  139.   titles2 AS STRING * 25
  140.   amount AS STRING * 3
  141. END TYPE
  142.  
  143. DIM arecord AS recordtype
  144. DIM firstrecord AS checkrecord
  145.  
  146. ' FORMAT OUTPUT HEADER DISPLAY
  147. CLS
  148.  
  149. a1$ = "SUBJECT Version 3.0 - A RBBS-PC Automatic Conference Welcome-file Maker"
  150. a2$ = STRING$(LEN(a1$), CHR$(205))
  151. a3$ = "Written by Vaishnava dasa - Krishna Yoga Foundation BBS"
  152. a4$ = "FidoNet 1:115/800 - 312/743-6116"
  153. a5$ = CHR$(34) + "Chant " + CHR$(96) + "Hare Krishna" + CHR$(39) + " and be happy" + CHR$(34)
  154. a6$ = "Use SUBJECT 3.0 with RBBS-PC Version 17.3"
  155. a7$ = "SUBJECT is also ideal with MSGTOSS:  The Fast RBBS-PC Mail-tosser!"
  156. a$ = a1$
  157. CALL center(a$, pad, ret)
  158. a$ = a2$
  159. CALL center(a$, pad, ret)
  160. a$ = a3$
  161. CALL center(a$, pad, ret)
  162. a$ = a4$
  163. CALL center(a$, pad, ret)
  164. a$ = a5$
  165. CALL center(a$, pad, ret)
  166. PRINT
  167. a$ = a6$
  168. CALL center(a$, pad, ret)
  169. a$ = a7$
  170. CALL center(a$, pad, ret)
  171. restrow = CSRLIN
  172. restcol = POS(0)
  173.  
  174.  
  175. ' SET UP ARRAY FOR SCREEN SAVING
  176. DIM SCR(2000)
  177. DSEG = VARSEG(SCR(1))
  178. DOFS = VARPTR(SCR(1))
  179. page = 0
  180. scrmode = -1
  181. CALL DSCRSAVE(DSEG, DOFS, page, scrmode)
  182. CLS
  183.  
  184. ' OPEN THE INPUT FILE AND READ SUBJECTS
  185. OPEN filename$ FOR RANDOM SHARED AS #1
  186. GET #1, 1, firstrecord
  187. xx1$ = firstrecord.maximess
  188.  
  189. ' NUMBER OF LAST MESSAGE IN MESSAGE BASE
  190. max.mess = VAL(xx1$)
  191.  
  192. ' RECORD NUMBER OF FIRST MESSAGE IN MESSAGE BASE
  193. xx2$ = firstrecord.locatefirstmess
  194. first.recno = VAL(xx2$)
  195.  
  196. ' READ FIRST MESSAGE HEADER RECORD GET NUMBER OF THIS MESSAGE
  197. GET #1, first.recno, arecord
  198. xx3$ = arecord.numb1mess
  199. first.messno = VAL(xx3$)
  200.  
  201. ' GET TOTAL NUMBER OF MESSAGES IN MESSAGE BASE POSSIBLE
  202. maxi = max.mess - first.messno + 1
  203.  
  204. ' DEFINE 2 ARRAYS SUITABLE TO FIT
  205. DIM myarray(1 TO (maxi + 1)) AS tosort
  206. DIM mysorted(1 TO (maxi + 1)) AS tosort2
  207.  
  208. ' ASSIGN NUMBER OF FIRST MESSAGE HEADER RECORD NUMBER TO "Q"
  209. q = first.recno
  210.  
  211. ' Y -> THE NUMBER OF ACTUAL SUBJECTS IN THIS MESSAGE BASE
  212. y = 0
  213.  
  214. olddate$ = "991231"
  215. recentdate$ = "800101"
  216.  
  217. ' GET THE FIRST MESSAGE HEADER RECORD
  218. GET #1, q, arecord
  219.  
  220. ' NEW DISPLAY PORT FOR WATCHING MESSAGES
  221. COLOR 14, 1
  222. LOCATE 1, 1
  223. PRINT STRING$(2000, CHR$(240));
  224. LOCATE 1, 1
  225. ulr = 5: ulc = 24
  226. lrr = 19: lrc = 56
  227. CALL mwindow(ulr, ulc, lrr, lrc)
  228. LOCATE ulr, ulc
  229. fore = 15: back = 19
  230. frame = 1: label$ = "Subject:"
  231. shadow = 0
  232. grow = 1
  233.  
  234. CALL WindowManager(ulr, ulc, lrr, lrc, frame, fore, back, grow, shadow, label, label$, page, scrmode)
  235. ' GOTO BOTTOM OF WINDOW
  236. LOCATE lrr, ulc + 1
  237.  
  238. ' LOOP AGAIN UNTIL EXIT; Y MUST BE LESS THAN CALCULATED MAXIMUM
  239. COLOR 15, 11
  240. DO WHILE y <= maxi
  241.  
  242.   ' IF MESSAGE IS PRIVATE, "(R)", OR BLANK, THEN DISREGARD
  243.   IF arecord.private = "*" OR RTRIM$(arecord.subject) = "(R)" OR LEN(RTRIM$(LTRIM$(arecord.subject))) = 0 OR arecord.alive = CHR$(226) THEN
  244.   
  245.     ' UPDATE TO GET NEXT RECORD HEADER
  246.     q = q + VAL(arecord.recnos)
  247.   
  248.     ' CHECK NEXT RECORD FOR BAD RECORD NUMBER INFO, IF SO, ABORT
  249.     IF LEN(RTRIM$(LTRIM$(arecord.subject))) = 0 THEN
  250.       ' ENCOUNTERED BLANK SUBJECT FIELD
  251.       GET #1, q, arecord
  252.       IF VAL(arecord.recnos) <= 0 OR VAL(arecord.recnos) > 9999 THEN
  253.         y = y - 1
  254.         EXIT DO
  255.       END IF
  256.     END IF
  257.     IF VAL(arecord.numb1mess) = VAL(xx1$) THEN
  258.       y = y - 1
  259.       EXIT DO
  260.     END IF
  261.   ' MESSAGE IS OK, THEREFORE CONTINUE TO PROCESS
  262.   ELSE
  263.     
  264.     ' CHECK FOR NULLS IN SUBJECT AND REPLACE WITH SPACES
  265.     IF INSTR(arecord.subject, CHR$(0)) <> 0 THEN
  266.       DO WHILE INSTR(arecord.subject, CHR$(0)) <> 0
  267.         x = INSTR(arecord.subject, CHR$(0))
  268.         arecord.subject = MID$(arecord.subject, 1, x - 1) + " " + MID$(arecord.subject, x + 1, 25)
  269.       LOOP
  270.     END IF
  271.   
  272.     ' CHECK FOR (R)s AND REMOVE IF FOUND
  273.     DO
  274.       IF LEFT$(arecord.subject, 3) = "(R)" THEN
  275.         arecord.subject = MID$(arecord.subject, 4, 25)
  276.       END IF
  277.     LOOP WHILE LEFT$(arecord.subject, 3) = "(R)"
  278.   
  279.     ' CHECK FOR "RE:"s AND REMOVE IF FOUND
  280.     DO
  281.       IF LEFT$(arecord.subject, 3) = "RE:" THEN
  282.         arecord.subject = MID$(arecord.subject, 4, 25)
  283.       END IF
  284.     LOOP WHILE LEFT$(arecord.subject, 3) = "RE:"
  285.   
  286.     ' BEGIN ARRAY NUMBERS WITH "1"
  287.     IF y = 0 THEN y = 1
  288.     
  289.     ' STORE NUMBER "y" AND SUBJECT TO ARRAY
  290.     myarray(y).titles = arecord.subject
  291.   
  292.     ' GET NEXT MESSAGE HEADER RECORD NUMBER
  293.     q = q + VAL(arecord.recnos)
  294.  
  295.     ' GET MESSAGE DATE OF THIS MESSAGE IN YYMMDD FORMAT
  296.     messdate$ = arecord.yydate + arecord.mmdate + arecord.dddate
  297.  
  298.     ' CHECK TO SEE VALIDITY OF THIS DATE (NO ZEROS)
  299.     IF VAL(arecord.yydate) <> 0 AND VAL(arecord.mmdate) <> 0 AND VAL(arecord.dddate) <> 0 THEN
  300.    
  301.       ' COMPARE AGAINST OLDEST MESSAGE DATE AND REPLACE VALUE IF OLDER
  302.       IF LEFT$(messdate$, 1) <> " " AND messdate$ < olddate$ THEN
  303.         olddate$ = messdate$
  304.       END IF
  305.    
  306.       ' COMPARE AGAINST MOST RECENT DATE MESSAGE AND UPDATE IF NEED BE
  307.       IF messdate$ > recentdate$ THEN recentdate$ = messdate$
  308.     END IF
  309.  
  310.     ' FOR DISPLAY, SHOW SUBJECTS
  311.     PRINT RIGHT$("  " + STR$(y), 3) + " - " + LEFT$(arecord.subject, 1) + MID$(LCASE$(arecord.subject), 2)
  312.     CALL scroll(ulr, ulc, lrr, lrc, 1)
  313.     LOCATE lrr, ulc + 1
  314.    
  315.     ' IF FIRST MESSAGE IS LAST MESSAGE THEN EXIT DO
  316.     IF VAL(arecord.numb1mess) = VAL(xx1$) THEN EXIT DO
  317.  
  318.     ' INCREMENT Y VARIABLE FOR COUNTING
  319.     y = y + 1
  320.  
  321.     ' IF Y IS LARGER THAN ARRAY SIZE THEN LOWER BY 1 AND GET OUT
  322.     IF y > maxi THEN
  323.       y = y - 1
  324.       EXIT DO
  325.     END IF
  326.   END IF
  327.   GET #1, q, arecord
  328. LOOP
  329.  
  330. IF y < 0 THEN y = 0
  331.  
  332. ' FORMAT DATES WITH DASHES
  333. olddate$ = MID$(olddate$, 3, 2) + "-" + RIGHT$(olddate$, 2) + "-" + LEFT$(olddate$, 2)
  334. recentdate$ = MID$(recentdate$, 3, 2) + "-" + RIGHT$(recentdate$, 2) + "-" + LEFT$(recentdate$, 2)
  335.  
  336. ' CLOSE THIS FILE AND SORT THE ARRAY
  337. CLOSE #1
  338.  
  339. ' FOR DISPLAY, SHOW END OF SCAN
  340. FOR x = 1 TO 14
  341.   PRINT
  342.   CALL scroll(ulr, ulc, lrr, lrc, 1)
  343.   LOCATE lrr, ulc + 1
  344. NEXT x
  345. PRINT RIGHT$("  " + STR$(y), 3) + " - Messages total"
  346. CALL scroll(ulr, ulc, lrr, lrc, 1)
  347. FOR x = 1 TO 13
  348.   PRINT
  349.   CALL scroll(ulr, ulc, lrr, lrc, 1)
  350.   LOCATE lrr, ulc + 1
  351. NEXT x
  352.  
  353. 'RESTORE TO DIFFERENT COLOR
  354. COLOR 15, 4
  355. LOCATE 2, 1
  356. a$ = SPACE$(LEN(a$))
  357. CALL center(a$, pad, ret)
  358.  
  359. a$ = "Sorting..."
  360. LOCATE 2, 1
  361. CALL center(a$, pad, ret)
  362.  
  363.   offset = y \ 2
  364.   DO WHILE offset > 0
  365.     Limit = y - offset
  366.     DO
  367.       switch = false
  368.       FOR counting = 1 TO Limit
  369.         IF myarray(counting).titles > myarray(counting + offset).titles THEN
  370.            SWAP myarray(counting), myarray(counting + offset)
  371.            switch = counting
  372.         END IF
  373.       NEXT counting
  374.       Limit = switch - offset
  375.     LOOP WHILE switch
  376.     offset = offset \ 2
  377.   LOOP
  378.  
  379. ' TAKE THE ARRAY AND FILL SECOND ARRAY (MYSORTED) WITH SUBJECT AND AMOUNTS
  380. f = 1
  381. FOR doit = 1 TO y
  382.   x = 1
  383.   mysorted(f).titles2 = myarray(doit).titles
  384.   FOR newdoit = (doit + 1) TO y + 1
  385.   IF myarray(newdoit).titles = myarray(doit).titles THEN
  386.     x = x + 1
  387.   ELSE
  388.     mysorted(f).amount = RIGHT$(("  " + LTRIM$(STR$(x))), 3)
  389.     doit = newdoit - 1
  390.     newdoit = y + 1
  391.   END IF
  392.   NEXT newdoit
  393. f = f + 1
  394. NEXT doit
  395.  
  396. ERASE myarray
  397.  
  398. ' SORTING MYSORTED ARRAY BY TOTALS
  399. f = f - 1
  400. LOCATE 2, 1
  401. a$ = SPACE$(LEN(a$))
  402. CALL center(a$, pad, ret)
  403. a$ = "Totaling..."
  404. LOCATE 2, 1
  405. CALL center(a$, pad, ret)
  406.  
  407.  
  408. offset = f \ 2
  409. DO WHILE offset > 0
  410.   Limit = f - offset
  411.   DO
  412.     switch = false
  413.     FOR counting = 1 TO Limit
  414.       IF mysorted(counting).amount < mysorted(counting + offset).amount THEN
  415.         SWAP mysorted(counting), mysorted(counting + offset)
  416.         switch = counting
  417.       ELSE
  418.         IF mysorted(counting).amount = mysorted(counting + offset).amount THEN
  419.           IF mysorted(counting).titles2 > mysorted(counting + offset).titles2 THEN
  420.             SWAP mysorted(counting), mysorted(counting + offset)
  421.             switch = counting
  422.           END IF
  423.         END IF
  424.       END IF
  425.     NEXT counting
  426.     Limit = switch - offset
  427.   LOOP WHILE switch
  428.   offset = offset \ 2
  429. LOOP
  430.  
  431. ' REGULAR NON-GRAPHICS, NON-COLOR OUTPUT FILE
  432. USERFORMAT:
  433.  
  434. ' ASSIGN INPUTFILE NAME TO NAME$
  435. name$ = filename$
  436.  
  437. ' PARSE NAME$ TO GET PATH AND NAME OF INPUT FILE
  438. DO WHILE INSTR(name$, "\") <> 0
  439.   c = INSTR(filename$, "\")
  440.   name$ = MID$(name$, c + 1, 255)
  441.   D = c + D
  442.   path$ = LEFT$(filename$, D)
  443. LOOP
  444.  
  445. ' CHECK FOR 'M.DEF' EXTENSION OF NAME$
  446. IF INSTR(name$, "M.DEF") <> 0 THEN name$ = LEFT$(name$, INSTR(name$, "M.DEF") - 1)
  447.  
  448. ' TEST TO SEE WHAT FILE TO USE AS A TEMPLATE
  449. IF INSTR(name$, ".") = 0 THEN
  450.  
  451.   ' THE INPUT FILENAME HAS NO EXTENSION...
  452.   OPEN name$ + ".TMP" FOR APPEND SHARED AS #1
  453.  
  454.   ' CHECK TO SEE IF THERE IS A TEMPLATE FILE IN THE DEFAULT DIRECTORY FOR THIS
  455.   IF LOF(1) = 0 THEN
  456.     CLOSE #1
  457.     KILL name$ + ".TMP"
  458.     OPEN "subject.tmp" FOR INPUT SHARED AS #1
  459.     templefile$ = "SUBJECT.TMP"
  460.   ELSE
  461.     IF LOF(1) > 0 THEN
  462.       CLOSE #1
  463.       OPEN name$ + ".TMP" FOR INPUT SHARED AS #1
  464.       templefile$ = name$ + ".TMP"
  465.     END IF
  466.   END IF
  467. ELSE
  468.  
  469.   ' NO EXTENSION ON THIS FILE...USE DEFAULT SUBJECT.TMP FILE
  470.   OPEN "subject.tmp" FOR INPUT SHARED AS #1
  471.   templefile$ = "SUBJECT.TMP"
  472. END IF
  473. c = 0
  474. D = 0
  475.  
  476. ' OUTPUT FILE PROCESSING
  477. outname$ = outputfile$
  478. DO WHILE INSTR(outname$, "\") <> 0
  479.   c = INSTR(outputfile$, "\")
  480.   outname$ = MID$(outname$, c + 1, 255)
  481.   D = c + D
  482.   path$ = LEFT$(outputfile$, D)
  483. LOOP
  484.  
  485. ' PARSE OUTPUT FILENAME TO GET MESSAGE BASE NAME WITHOUT W.DEF
  486. IF INSTR(outname$, "W.DEF") <> 0 THEN
  487.   outname$ = LEFT$(outname$, INSTR(outname$, "W.DEF") - 1)
  488. END IF
  489.  
  490. ' IF NAME IS TOO LONG SET VARIABLE TO TRUE
  491. IF LEN(outname$) >= 7 THEN nametoolong = -1
  492.  
  493. ' OPEN THE FILE FOR NON-GRAPHICS, NON-COLOR OUTPUT FILE, REGULAR *W.DEF FILE
  494. OPEN outputfile$ FOR OUTPUT SHARED AS #2
  495. outfile$ = outputfile$
  496. IF LEN(confname$) >= 20 THEN confname$ = LEFT$(confname$, 20)
  497. IF LEN(confname$) < 20 THEN confname$ = LEFT$(confname$ + SPACE$(20), 20)
  498.  
  499. ' IF NO MESSAGES, MAKE SURE DATES ARE RESET PROPERLY
  500. IF y = 0 THEN
  501.   recentdate$ = "00-00-00"
  502.   olddate$ = "00-00-00"
  503. END IF
  504.  
  505. ' FORMAT 'MSG' OUTPUT OR, NUMBER OF MESSAGES IN MESSAGE BASE TO 3 CHARACTERS
  506. IF y > 0 THEN
  507.   IF y >= 1 AND y < 10 THEN
  508.     messages$ = "  " + LTRIM$(STR$(y))
  509.   ELSE
  510.     IF y >= 10 AND y < 100 THEN
  511.       messages$ = " " + LTRIM$(STR$(y))
  512.     ELSE
  513.       IF y >= 100 AND y < 1000 THEN
  514.         messages$ = LTRIM$(STR$(y))
  515.       END IF
  516.     END IF
  517.   END IF
  518. END IF
  519. IF y = 0 THEN messages$ = "  0"
  520.  
  521. ' THIS ROUTINE READS TEMPLATE FILE AND REPLACES ALL VARIABLES WITH REAL INFO
  522. ' THEN CLOSES THE FILE
  523. userformat2:
  524. a = 0
  525. b = 0
  526. DO WHILE NOT EOF(1)
  527.   LINE INPUT #1, x$
  528.   IF INSTR(x$, "TODATExx") <> 0 THEN
  529.     z = INSTR(x$, "TODATExx")
  530.     x$ = MID$(x$, 1, (z - 1)) + recentdate$ + MID$(x$, z + 8, 255)
  531.   END IF
  532.   IF INSTR(x$, "FMDATExx") <> 0 THEN
  533.     z = INSTR(x$, "FMDATExx")
  534.     x$ = MID$(x$, 1, (z - 1)) + olddate$ + MID$(x$, z + 8, 255)
  535.   END IF
  536.   IF INSTR(x$, "MSG") <> 0 THEN
  537.     z = INSTR(x$, "MSG")
  538.     x$ = MID$(x$, 1, (z - 1)) + messages$ + MID$(x$, z + 3, 255)
  539.   END IF
  540.   IF INSTR(x$, "AREA") <> 0 THEN
  541.     z = INSTR(x$, "AREA")
  542.     x$ = MID$(x$, 1, (z - 1)) + RTRIM$(confname$) + MID$(x$, z + LEN(RTRIM$(confname$)), 255)
  543.   END IF
  544.   DO WHILE INSTR(x$, "###") <> 0 OR INSTR(x$, "SUBJECT890123456789012345") <> 0
  545.     IF INSTR(x$, "###") <> 0 THEN
  546.       z = INSTR(x$, "###")
  547.       IF INSTR(mysorted(a + 1).amount, CHR$(0)) = 0 THEN
  548.         x$ = MID$(x$, 1, (z - 1)) + mysorted(a + 1).amount + MID$(x$, z + 3, 255)
  549.         IF f >= a THEN a = a + 1
  550.       ELSE
  551.         x$ = MID$(x$, 1, (z - 1)) + "   " + MID$(x$, z + 3, 255)
  552.         IF f >= a THEN a = a + 1
  553.       END IF
  554.     END IF
  555.     IF INSTR(x$, "SUBJECT890123456789012345") <> 0 THEN
  556.       z = INSTR(x$, "SUBJECT890123456789012345")
  557.       IF INSTR(mysorted(b + 1).titles2, CHR$(0)) = 0 THEN
  558.         x$ = MID$(x$, 1, (z - 1)) + mysorted(b + 1).titles2 + MID$(x$, z + 25, 255)
  559.         IF f >= b THEN b = b + 1
  560.       ELSE
  561.         x$ = MID$(x$, 1, (z - 1)) + SPACE$(25) + MID$(x$, z + 25, 255)
  562.         IF f >= b THEN b = b + 1
  563.       END IF
  564.     END IF
  565.   LOOP
  566.   PRINT #2, x$
  567. LOOP
  568. CLOSE
  569. IF NOT asciido THEN
  570.   a$ = "Now on disk: "
  571.   count = 1
  572. END IF
  573. IF LEN(outfile$) > 21 THEN
  574.   IF count = 1 THEN outfile$ = "non-graphics"
  575.   IF count = 2 THEN outfile$ = "graphics"
  576.   IF count = 3 THEN outfile$ = "color-graphics"
  577. END IF
  578. a$ = a$ + LCASE$(outfile$)
  579. LOCATE 2, 1
  580. CALL center(a$, pad, ret)
  581. count = count + 1
  582.  
  583. a$ = RTRIM$(a$)
  584.  
  585. IF asciido = false GOTO ASCIIMARK
  586. IF colordo = false GOTO COLORMARK
  587. LOCATE 23, 1
  588. CALL delayit(3, false)
  589. GOTO finish
  590.  
  591. ASCIIMARK:
  592. asciido = true
  593.  
  594. ' IF INPUTFILE NAME TOO LONG CAN'T MAKE GRAPHICS OR COLOR FILE
  595. IF nametoolong THEN
  596.   GOTO finish
  597. END IF
  598.  
  599. ' CONTINUE TO PROCESS, UPDATE OUTPUT STRING FOR SCREEN DISPLAY
  600. a$ = a$ + ", "
  601.  
  602. ' CHECK FOR SPECIAL *G.TMP FILE
  603. OPEN name$ + "G.TMP" FOR APPEND SHARED AS #1
  604. IF LOF(1) = 0 THEN
  605.   CLOSE #1
  606.   KILL name$ + "G.TMP"
  607.   OPEN "subjectg.tmp" FOR INPUT SHARED AS #1
  608.   templefile$ = "SUBJECTG.TMP"
  609. ELSE
  610.   CLOSE #1
  611.   OPEN name$ + "G.TMP" FOR INPUT SHARED AS #1
  612.   templefile$ = name$ + "G.TMP"
  613. END IF
  614. c = 0
  615. D = 0
  616. nameout$ = outputfile$
  617. path$ = ""
  618. DO WHILE INSTR(nameout$, "\") <> 0
  619.   c = INSTR(outputfile$, "\")
  620.   nameout$ = MID$(nameout$, c + 1, 255)
  621.   D = c + D
  622.   path$ = LEFT$(outputfile$, D)
  623. LOOP
  624. IF INSTR(nameout$, "W.DEF") <> 0 THEN
  625.    nameout$ = LEFT$(nameout$, INSTR(nameout$, "W.DEF") - 1)
  626. END IF
  627. outputgfile$ = path$ + nameout$ + "WG.DEF"
  628. OPEN outputgfile$ FOR OUTPUT SHARED AS #2
  629. outfile$ = outputgfile$
  630. GOTO userformat2
  631.  
  632. COLORMARK:
  633. colordo = true
  634.  
  635. ' CONTINUE TO PROCESS, UPDATE OUTPUT STRING FOR SCREEN DISPLAY
  636. a$ = a$ + ", "
  637.  
  638. OPEN name$ + "C.TMP" FOR APPEND SHARED AS #1
  639. IF LOF(1) = 0 THEN
  640.   CLOSE #1
  641.   KILL name$ + "C.TMP"
  642.   OPEN "subjectc.tmp" FOR INPUT SHARED AS #1
  643.   templefile$ = "SUBJECTC.TMP"
  644. ELSE
  645.   CLOSE #1
  646.   OPEN name$ + "C.TMP" FOR INPUT SHARED AS #1
  647.   templefile$ = name$ + "C.TMP"
  648. END IF
  649. c = 0
  650. D = 0
  651. nameout$ = outputfile$
  652. path$ = ""
  653. DO WHILE INSTR(nameout$, "\") <> 0
  654.   c = INSTR(outputfile$, "\")
  655.   nameout$ = MID$(nameout$, c + 1, 255)
  656.   D = c + D
  657.   path$ = LEFT$(outputfile$, D)
  658. LOOP
  659. IF INSTR(nameout$, "W.DEF") <> 0 THEN
  660.    nameout$ = LEFT$(nameout$, INSTR(nameout$, "W.DEF") - 1)
  661. END IF
  662. outputcfile$ = path$ + nameout$ + "WC.DEF"
  663. OPEN outputcfile$ FOR OUTPUT SHARED AS #2
  664. outfile$ = outputcfile$
  665. GOTO userformat2
  666.  
  667. finish:
  668. CLOSE
  669. IF nametoolong THEN
  670.   COLOR 0, 7
  671.   LOCATE 2, 1
  672.   a$ = "Conference name too long to make Graphics or Color Welcome files"
  673.   CALL center(a$, pad, ret)
  674.   PRINT
  675.   LOCATE 22, 1
  676.   CALL delayit(20, true)
  677. END IF
  678. GOTO theend
  679.  
  680. showcommands:
  681. CLS
  682. a$ = "Required format for SUBJECT.EXE (Version 3.0):"
  683. CALL center(a$, pad, ret)
  684. a$ = "══════════════════════════════════════════════"
  685. CALL center(a$, pad, ret)
  686. a$ = "SUBJECT I:file O:file C:name (? = Help)"
  687. CALL center(a$, pad, ret)
  688. PRINT
  689. a$ = "Template (SUBJECT?.TMP) files must be on the default drive/directory"
  690. CALL center(a$, pad, ret)
  691. a$ = "For complete compatibility, use 6 characters or less for your RBBS-PC"
  692. CALL center(a$, pad, ret)
  693. a$ = "Messages files (e.g. 'optionM.DEF')"
  694. CALL center(a$, pad, ret)
  695. PRINT
  696. a$ = "Examples:"
  697. CALL center(a$, pad, ret)
  698. a$ = "SUBJECT i:c:\rbbs\rbbspcM.DEF o:c:\rbbs\rbbspcW.DEF c:rbbs-pc "
  699. CALL center(a$, pad, ret)
  700. a$ = "SUBJECT i:binkM.DEF o:binkW.DEF c:binkleyterm "
  701. CALL center(a$, pad, ret)
  702. PRINT
  703. a$ = "Required command-line parameters:"
  704. CALL center(a$, pad, ret)
  705. a$ = "i: - Name of Input RBBS-PC Messages file to read"
  706. CALL center(a$, pad, ret)
  707. a$ = "o: - Name of Output file to create"
  708. CALL center(a$, pad, ret)
  709. a$ = "c: - Name of Conference--Do NOT use any [SPACE] characters"
  710. CALL center(a$, pad, ret)
  711. IF NOT helptext THEN
  712.   IF LEN(COMMAND$) > 0 THEN
  713.     PRINT
  714.     a$ = "Correct the current command-line:"
  715.     CALL center(a$, pad, ret)
  716.     a$ = "SUBJECT " + COMMAND$
  717.     CALL center(a$, pad, ret)
  718.   END IF
  719. ELSE
  720.   PRINT
  721.   a$ = "Options:"
  722.   CALL center(a$, pad, ret)
  723.   a$ = "SUBJECT also looks for special *.TMP files so that you can customize"
  724.   CALL center(a$, pad, ret)
  725.   a$ = "Welcome files for your conferences.  Rather than using the default "
  726.   CALL center(a$, pad, ret)
  727.   a$ = "SUBJECT?.TMP files, you can create your own for any particular conference"
  728.   CALL center(a$, pad, ret)
  729.   a$ = "and SUBJECT will look for that one first, and use it, if it matches the"
  730.   CALL center(a$, pad, ret)
  731.   a$ = "name of the message file (e.g. 'other.TMP,' 'otherG.TMP,' or 'otherC.TMP'"
  732.   CALL center(a$, pad, ret)
  733.   a$ = "for the Conference 'otherM.DEF.'  Read documentation for more details."
  734.   CALL center(a$, pad, ret)
  735. END IF
  736. PRINT
  737. CALL delayit(120, true)
  738. GOTO theend
  739.  
  740. HANDLER:
  741. listen$ = "t180 o1 p2 p8 l8 ggg l1 e-"
  742. fate$ = "t140 p24 p8 l8 fff t110 l1 d P2"
  743. PLAY listen$ + fate$
  744. number = ERR
  745. IF number = 63 THEN
  746.   CLOSE #1
  747.   KILL filename$
  748.   OPEN "subject.err" FOR APPEND SHARED AS #2
  749.   LOCATE 11, 1
  750.   PRINT SPACE$(80 * 3);
  751.   LOCATE 12, 1
  752.   COLOR 0, 7, 0
  753.   a$ = "Basic Error 63:  Specified RBBS-PC Messages file NOT FOUND!"
  754.   CALL center(a$, pad, 0)
  755.   COLOR 7, 0, 0
  756.   PRINT #2, "An error has occured running SUBJECT.EXE at:"
  757.   PRINT #2, "  Date:  "; DATE$; ";  Time:  "; TIME$
  758.   PRINT #2, "  Processing Messages file: "; filename$
  759.   PRINT #2, "  Check if the Message file exists in the proper directory."
  760.   PRINT #2, "---"
  761.   PRINT
  762.   LOCATE 23
  763.   CALL delayit(30, true)
  764.   ON ERROR GOTO theend
  765. ELSE
  766.   CLOSE
  767.   LOCATE 11, 1
  768.   PRINT SPACE$(80 * 4);
  769.   LOCATE 12, 1
  770.   COLOR 0, 7, 0
  771.   a$ = "SUBJECT encountered untrapped error number " + LTRIM$(STR$(number))
  772.   CALL center(a$, pad, 1)
  773.   COLOR 7, 0, 0
  774.   COLOR 0, 7, 0
  775.   a$ = "Refer to your BASIC manual for more information about this Error code"
  776.   CALL center(a$, pad, 1)
  777.   COLOR 7, 0, 0
  778.   OPEN "subject.err" FOR APPEND SHARED AS #2
  779.   PRINT #2, "An error has occured running SUBJECT.EXE at:"
  780.   PRINT #2, "  Date:  "; DATE$; ";  Time:  "; TIME$
  781.   PRINT #2, "  Processing Messages file: "; filename$
  782.   PRINT #2, "  SUBJECT.EXE encountered untrapped error number"; number
  783.   PRINT #2, "  Read your BASIC manual for more information about this Error code."
  784.   PRINT #2, "---"
  785.   LOCATE 23
  786.   CALL delayit(30, true)
  787.   ON ERROR GOTO theend
  788. END IF
  789.  
  790. theend:
  791. ' FOR RESTORING, USE THIS
  792. page = 0
  793. scrmode = -1
  794. DSEG = VARSEG(SCR(1))
  795. DOFS = VARPTR(SCR(1))
  796. CALL DSCRREST(DSEG, DOFS, page, scrmode)
  797. LOCATE restrow, restcol
  798. END
  799.  
  800. SUB center (a$, pad, ret)
  801.   a$ = SPACE$(pad) + RTRIM$(LTRIM$(a$)) + SPACE$(pad)
  802.   col! = ((80 - LEN(a$)) / 2)
  803.   IF INSTR(STR$(col!), ".5") <> 0 THEN col! = col! - .5
  804.   LOCATE , col! + 1
  805.   PRINT a$;
  806.   IF ret <> 0 THEN PRINT
  807. END SUB
  808.  
  809. SUB comline (NumArgs, Args$(), MaxArgs) STATIC
  810. CONST false = 0, true = NOT false
  811. NumArgs = 0
  812. in = false
  813. c1$ = COMMAND$
  814. L = LEN(c1$)
  815. FOR I = 1 TO L
  816.   c$ = MID$(c1$, I, 1)
  817.   IF (c$ <> " " AND c$ <> CHR$(9)) THEN
  818.     IF NOT in THEN
  819.       IF NumArgs = MaxArgs THEN EXIT FOR
  820.       NumArgs = NumArgs + 1
  821.       in = true
  822.     END IF
  823.     Args$(NumArgs) = Args$(NumArgs) + c$
  824.   ELSE
  825.     in = false
  826.   END IF
  827. NEXT I
  828. END SUB
  829.  
  830. SUB delayit (secs, display)
  831.   COLOR 15, 4
  832.   start! = TIMER
  833.   DO WHILE INKEY$ = ""
  834.     LOCATE , 1
  835.     finish! = TIMER
  836.     IF display THEN
  837.       a$ = "Wait " + LTRIM$(STR$(INT(secs - (finish! - start!)))) + " seconds or press any key to continue..."
  838.       CALL center(a$, 1, 0)
  839.     END IF
  840.     IF finish! - start! > secs THEN
  841.       EXIT DO
  842.     END IF
  843.     FOR x = 1 TO 500
  844.       IF INKEY$ <> "" THEN
  845.         EXIT DO
  846.       END IF
  847.     NEXT x
  848.   LOOP
  849. END SUB
  850.  
  851.